package com.example.demo.util;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@ToString
@NoArgsConstructor
public class ResultBean implements Serializable {

    private Integer code;

    private String msg;

    private Object result;


    public static String setResult(int code, String msg, Object result) {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("msg", msg);
        map.put("result", result);
        return JSONObject.toJSONString(map, SerializerFeature.WriteMapNullValue);
    }

}
